package com.ruixi.mapper;

import com.ruixi.entity.SequenceBean;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * @author lrzg
 * @date 2021-05-12 14:53
 * @Description 流水生成Mapper类
 */
@Repository
public interface SequenceMapper {

    /**
     * 根据日期获取
     * @param seqType
     * @param seqDay
     * @return
     */

    @Select("select id as id,seq_type as seqType,seq_day as seqDay,seq_value as seqValue,describes as describes,create_time as createTime,update_time as updateTime,version as version from sequence where seq_type=#{seqType} and seq_day= #{seqDay}")
    SequenceBean selectByDay(@Param("seqType")String seqType, @Param("seqDay")String seqDay);

    /**
     * 插入数据
     * @param seqType
     * @param seqDay
     * @param seqValue
     * @return
     */
    @Insert("insert into sequence (seq_type,seq_day,seq_value,describes,create_time,update_time,version) values(#{seqType},#{seqDay},#{seqValue},#{describes},now(),now(),#{version})")
    void insertValue(@Param("seqType")String seqType,@Param("describes")String describes , @Param("seqDay")String seqDay, @Param("seqValue")long seqValue,@Param("version")long version);


    int updateValByDay(@Param("seqType")String seqType, @Param("seqDay")String seqDay, @Param("oldSeqValue")long oldSeqValue, @Param("newSeqValue")long newSeqValue);
}
